package com.project.common.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.project.common.entity.PageVo;
import com.project.common.entity.SysUsers;
import com.project.common.mapper.SysUsersMapper;
import com.project.common.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class SysUsersImpl implements SysUserService {
    @Autowired
    private SysUsersMapper sysUsersMapper;
    @Override
    public SysUsers queryUserByName(String userName) {
        return sysUsersMapper.queryUserByName(userName);
    }

    @Override
    public PageVo<SysUsers> queryAllUser(Map<String, String> map) {
        Integer pageNum = Integer.valueOf(map.get("pageNum"));
        Integer pageSize= Integer.valueOf(map.get("pageSize"));
//        System.out.println(map);
        PageHelper.startPage(pageNum,pageSize);
        List<SysUsers> sysUsers = sysUsersMapper.queryAllUser();

        PageInfo<SysUsers> pageInfo = new PageInfo<SysUsers>(sysUsers);

        PageVo<SysUsers> pageVo = new PageVo<SysUsers>();
        pageVo.setRows(pageInfo.getList());
        pageVo.setTotal(pageInfo.getTotal());

        return pageVo;
    }

    @Override
    public List<SysUsers> queryAllUser() {
        return sysUsersMapper.queryAllUser();
    }

    @Override
    public SysUsers queryUserById(Integer id) {
        return sysUsersMapper.queryUserById(id);
    }

    @Override
    public int updateByPrimaryKeySelective(SysUsers record) {
        return sysUsersMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int insert(SysUsers record) {
        return sysUsersMapper.insert(record);
    }

    @Override
    public int insertSelective(SysUsers record) {
        return sysUsersMapper.insertSelective(record);
    }
}
